package com.st.shopadmin.controller;

import com.st.shopadmin.annotation.LoginAccess;
import com.st.shopadmin.common.ServerResponse;
import com.st.shopadmin.pojo.Shop;
import com.st.shopadmin.pojo.ShopUserPlat;
import com.st.shopadmin.service.ShopService;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/manage/shop/")
public class ShopManageController {

    @Autowired
    private ShopService shopService;

    /**
     * class_name: ShopManageController
     * package: com.stshop.controller
     * describe: 店铺列表(后端分页)
     * author: duhongpeng
     * date: 2018/10/22
     * time: 15:12
     **/
    @RequestMapping("list.do")
    @ResponseBody
    public ServerResponse getShopList(HttpServletRequest httpServletRequest, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "10") int pageSize){
            return shopService.getShopList(pageNum,pageSize);
    }

    /**
     * class_name: ShopManageController
     * package: com.stshop.controller
     * describe: 店铺列表(前端分页)
     * author: duhongpeng
     * date: 2018/10/22
     * time: 15:12
     **/
    @RequestMapping("lists.do")
    @ResponseBody
    @LoginAccess
    public ServerResponse getShopLists(HttpServletRequest httpServletRequest, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "10") int pageSize){
        ServerResponse<List> serverResponse = shopService.getShopLists(pageNum,pageSize);
        serverResponse.setTotal(serverResponse.getData().size());
        return serverResponse;
    }


    /**
     * class_name: ShopManageController
     * package: com.stshop.controller
     * describe: 店铺列表(查询分页)
     * author: duhongpeng
     * date: 2018/10/22
     * time: 15:12
     **/
    @RequestMapping("newSearchLists.do")
    @ResponseBody
    public ServerResponse searchLists(HttpServletRequest httpServletRequest, Shop shop,@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "10") int pageSize){
        ServerResponse<List> serverResponse = shopService.searchLists(shop,pageNum,pageSize);
        serverResponse.setTotal(serverResponse.getData().size());
        return serverResponse;
    }

    /**
     * class_name: ShopManageController
     * package: com.stshop.controller
     * describe: 店铺列表(查询分页)
     * author: duhongpeng
     * date: 2018/10/22
     * time: 15:12
     **/
    @RequestMapping("searchLists.do")
    @ResponseBody
    public ServerResponse newSearchLists(HttpServletRequest httpServletRequest, ShopUserPlat shop,@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "10") int pageSize){
        ServerResponse<List> serverResponse = shopService.newSearchLists(shop,pageNum,pageSize);
        serverResponse.setTotal(serverResponse.getData().size());
        return serverResponse;
    }



    /**
     * class_name: ShopManageController
     * package: com.stshop.controller
     * describe: 跳转列表页面
     * author: duhongpeng
     * date: 2018/10/23
     * time: 14:00
     **/
    @RequestMapping("getShopPageList.do")
    public String getShopPageList(HttpServletRequest httpServletRequest, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "10") int pageSize,Model model){
        return "shoplist";
    }

    @RequestMapping("index.do")
    public String index(HttpServletRequest httpServletRequest, @RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "10") int pageSize,Model model){
        return "views/index";
    }

    /**
     * class_name: ShopManageController
     * package: com.stshop.controller
     * describe:保存店铺信息
     * author: duhongpeng
     * date: 2018/10/23
     * time: 14:00
     **/
    @RequestMapping("shopSave.do")
    public ServerResponse shopSave(HttpServletRequest httpServletRequest, Shop shop){
        return  shopService.shopSave(shop);
    }

    /**
     * class_name: ShopManageController
     * package: com.stshop.controller
     * describe: 店铺详情
     * author: duhongpeng
     * date: 2018/10/22
     * time: 15:12
     **/
    @RequestMapping("detail.do")
    @ResponseBody
    public ServerResponse getShopDetail(HttpServletRequest httpServletRequest, Long shopId,Integer status){
            return  shopService.getShopDetail(shopId);
    }
    /**
     * class_name: ShopManageController
     * package: com.stshop.controller
     * describe: 修改店铺状态
     * author: duhongpeng
     * date: 2018/10/22
     * time: 15:12
     **/
    @RequestMapping("updateShopStatus.do")
    @ResponseBody
    public ServerResponse updateShopStatus(HttpServletRequest httpServletRequest,Long shopId,Integer status,String shopNoPassReasons){
        return shopService.updateShopStatus(shopId,status,shopNoPassReasons);
    }

    /**
     * class_name: ShopManageController
     * package: com.stshop.controller
     * describe: 修改店铺信息
     * author: duhongpeng
     * date: 2018/10/22
     * time: 15:12
     **/
    @RequestMapping("updateShop.do")
    @ResponseBody
    public ServerResponse updateShop(HttpServletRequest httpServletRequest,Shop shop){
        return shopService.updateShop(shop);
    }

}
